Functions | |
| void | UARTStdioInit (unsigned long ulPortNum) |
| int | UARTwrite (const char *pcBuf, unsigned long ulLen) |
| int | UARTgets (char *pcBuf, unsigned long ulLen) |
| unsigned char | UARTgetc (void) |
| void | UARTprintf (const char *pcString,...) |
| unsigned char UARTgetc | ( | void | ) |
Read a single character from the UART, blocking if necessary.
This function will receive a single character from the UART and store it at the supplied address.
In both buffered and unbuffered modes, this function will block until a character is received. If non-blocking operation is required in buffered mode, a call to UARTRxAvail() may be made to determine whether any characters are currently available for reading.
| int UARTgets | ( | char * | pcBuf, | |
| unsigned long | ulLen | |||
| ) |
A simple UART based get string function, with some line processing.
| pcBuf | points to a buffer for the incoming string from the UART. | |
| ulLen | is the length of the buffer for storage of the string, including the trailing 0. |
This function will receive a string from the UART input and store the characters in the buffer pointed to by pcBuf. The characters will continue to be stored until a termination character is received. The termination characters are CR, LF, or ESC. A CRLF pair is treated as a single termination character. The termination characters are not stored in the string. The string will be terminated with a 0 and the function will return.
In both buffered and unbuffered modes, this function will block until a termination character is received. If non-blocking operation is required in buffered mode, a call to UARTPeek() may be made to determine whether a termination character already exists in the receive buffer prior to calling UARTgets().
Since the string will be null terminated, the user must ensure that the buffer is sized to allow for the additional null character.
| void UARTprintf | ( | const char * | pcString, | |
| ... | ||||
| ) |
A simple UART based printf function supporting %c, %d, %p, %s, %u, %x, and %X.
| pcString | is the format string. | |
| ... | are the optional arguments, which depend on the contents of the format string. |
This function is very similar to the C library fprintf() function. All of its output will be sent to the UART. Only the following formatting characters are supported:
For %s, %d, %u, %p, %x, and %X, an optional number may reside between the % and the format character, which specifies the minimum number of characters to use for that value; if preceded by a 0 then the extra characters will be filled with zeros instead of spaces. For example, ``%8d'' will use eight characters to print the decimal value with spaces added to reach eight; ``%08d'' will use eight characters as well but will add zeroes instead of spaces.
The type of the arguments after pcString must match the requirements of the format string. For example, if an integer was passed where a string was expected, an error of some kind will most likely occur.
| void UARTStdioInit | ( | unsigned long | ulPortNum | ) |
Determines whether the ring buffer whose pointers and size are provided is full or not.
| pulRead | points to the read index for the buffer. | |
| pulWrite | points to the write index for the buffer. | |
| ulSize | is the size of the buffer in bytes. |
This function is used to determine whether or not a given ring buffer is full. The structure of the code is specifically to ensure that we do not see warnings from the compiler related to the order of volatile accesses being undefined.
| pulRead | points to the read index for the buffer. | |
| pulWrite | points to the write index for the buffer. |
This function is used to determine whether or not a given ring buffer is empty. The structure of the code is specifically to ensure that we do not see warnings from the compiler related to the order of volatile accesses being undefined.
| pulRead | points to the read index for the buffer. | |
| pulWrite | points to the write index for the buffer. | |
| ulSize | is the size of the buffer in bytes. |
This function is used to determine how many bytes of data a given ring buffer currently contains. The structure of the code is specifically to ensure that we do not see warnings from the compiler related to the order of volatile accesses being undefined.
| ulPortNum | is the number of UART port to use for the serial console (0-2) |
This function will initialize the specified serial port to be used as a serial console. The serial parameters will be set to 115200, 8-N-1.
This function must be called prior to using any of the other UART console functions: UARTprintf() or UARTgets(). In order for this function to work correctly, SysCtlClockSet() must be called prior to calling this function.
It is assumed that the caller has previously configured the relevant UART pins for operation as a UART rather than as GPIOs.
| int UARTwrite | ( | const char * | pcBuf, | |
| unsigned long | ulLen | |||
| ) |
Writes a string of characters to the UART output.
| pcBuf | points to a buffer containing the string to transmit. | |
| ulLen | is the length of the string to transmit. |
This function will transmit the string to the UART output. The number of characters transmitted is determined by the ulLen parameter. This function does no interpretation or translation of any characters. Since the output is sent to a UART, any LF (/n) characters encountered will be replaced with a CRLF pair.
Besides using the ulLen parameter to stop transmitting the string, if a null character (0) is encountered, then no more characters will be transmitted and the function will return.
In non-buffered mode, this function is blocking and will not return until all the characters have been written to the output FIFO. In buffered mode, the characters are written to the UART transmit buffer and the call returns immediately. If insufficient space remains in the transmit buffer, additional characters are discarded.
1.6.3